﻿Imports System.Data.SqlClient

Public Class frmModuloNominasBellavista
    Dim Bitacora As New clsActividad
    Dim Usuario As New clsUsuarioPrincipal
    Private Sub NuevaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NuevaToolStripMenuItem.Click
        NominaNueva = True

        frmNominaBellavista.ShowDialog()
    End Sub

    Private Sub RegresarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RegresarToolStripMenuItem.Click
        Dim resp As Integer = MsgBox("Deseas salir del Modulo de Nominas", MsgBoxStyle.YesNo, "Aviso")
        If resp = 6 Then
            Me.Close()
        End If
    End Sub

    Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
        Dim resp As Integer = MsgBox("Deseas salir del Modulo de Nominas", MsgBoxStyle.YesNo, "Aviso")
        If resp = 6 Then
            Me.Close()
        End If
    End Sub

    Private Sub ActualizarCatálogosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ActualizarCatálogosToolStripMenuItem.Click
        frmAdeudos.ShowDialog()
    End Sub

    Private Sub ToolStripButton5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton5.Click
        NominaNueva = True

        frmNominaBellavista.ShowDialog()
    End Sub
    Private Sub frmModuloNominas_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        Bitacora.RegistraActividad("Cerró el Módulo de Nominas")
        Usuario.Ubicacion("Ventana Principal")
    End Sub

    Private Sub frmModuloNominas_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ToolStrip2.Cursor = Cursors.Hand
        ToolStrip2.RenderMode = System.Windows.Forms.ToolStripRenderMode.System
        Actualizar()

        Bitacora.RegistraActividad("Ingresó al Módulo de Nominas")
        Usuario.Ubicacion("Módulo de Nominas")


    End Sub
    Sub Actualizar()
        Windows.Forms.Cursor.Current = Cursors.WaitCursor
        dgBuscar.Rows.Clear()

        Dim cnconn As New SqlConnection
        cnconn.ConnectionString = CitraConnection
        Dim strSql As String = ""
        cnconn.Open()
        Dim cmdBuscar As New SqlCommand
        cmdBuscar.Connection = cnconn
        Dim cmdAsignar As New SqlCommand
        cmdAsignar.Connection = cnconn

        strSql = "SELECT * FROM NominaGeneral ORDER BY FechaAplicacion"

        cmdBuscar.CommandText = strSql
        Dim rdBuscar As SqlDataReader
        rdBuscar = cmdBuscar.ExecuteReader

        Dim Inicial As Date
        Dim Final As Date
        Dim Aplicacion As Date

        Do While rdBuscar.Read()
            Inicial = rdBuscar("FechaInicial")
            Final = rdBuscar("FechaFinal")
            Aplicacion = rdBuscar("FechaAPlicacion")
            dgBuscar.Rows.Add(rdBuscar("Folio"), Aplicacion.Day & "/" & Aplicacion.Month & "/" & Aplicacion.Year, rdBuscar("Infonavit"), rdBuscar("Fonacot"), rdBuscar("Anio"), rdBuscar("Nomina"), Inicial.Day & "/" & Inicial.Month & "/" & Inicial.Year, Final.Day & "/" & Final.Month & "/" & Final.Year)
        Loop
    End Sub
    Private Sub dgBuscar_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgBuscar.DoubleClick
        Dim valorCell As Integer
        Dim valorRow As DataGridViewRow

        valorCell = Me.dgBuscar.CurrentCell.ColumnIndex
        valorRow = Me.dgBuscar.CurrentRow

        IDNomina = Me.dgBuscar.Rows(valorRow.Index).Cells(0).Value.ToString.Trim
        NominaNueva = False

        valorCellSelect = valorCell
        valorRowSelect = valorRow

        frmNominaBellavista.ShowDialog()

    End Sub

    Private Sub dgBuscar_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles dgBuscar.KeyPress
        Dim valorCell As Integer
        Dim valorRow As DataGridViewRow

        valorCell = Me.dgBuscar.CurrentCell.ColumnIndex
        valorRow = Me.dgBuscar.CurrentRow

        IDNomina = Me.dgBuscar.Rows(valorRow.Index).Cells(0).Value.ToString.Trim
        NominaNueva = False

        valorCellSelect = valorCell
        valorRowSelect = valorRow

        frmNominaBellavista.ShowDialog()


    End Sub

    Private Sub IngresoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IngresoToolStripMenuItem.Click
        frmNominasIngreso.ShowDialog()

    End Sub
End Class